﻿using System.IO.IsolatedStorage;

namespace GroupChallengeWP7
{
    public class Utils
    {
        internal static string GetSetting(string key)
        {
            string ret = string.Empty;

            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

            settings.TryGetValue<string>(key, out ret);

            // Set in a TextBlock so do not allow it to be null.
            if (null == ret)
                ret = string.Empty;

            return ret;
        }

        internal static void SaveSetting(string key, string value)
        {
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

            // Add the setting if not already.
            if (!settings.Contains(key))
                settings.Add(key, string.Empty);

            settings[key] = value;
            settings.Save();
        }

    }
}
